/**
 * Created by IntelliJ IDEA.
 * User: Awake
 * Date: 31.01.12
 * Time: 20:33
 * To change this template use File | Settings | File Templates.
 */
public class Calc {
    public static long operation(int first, int second, String oper) {
        long res = 0;
        char op = oper.charAt(0);

        switch (op) {
            case '+':
                res = first + second;
                break;
            case '-':
                res = first - second;
                break;
            case '*':
                res = first * second;
                break;

            case '/':
                try {
                    res = first / second;
                } catch (ArithmeticException e) {
                    throw new IllegalArgumentException("second argument is zero");
                }

                break;

            default:
                throw new IllegalArgumentException("invalid operation");
        }

        return res;
    }


}
